Cycling through ItemStacks whlie supplying data... LOST [on hold]

Posted by user3251606 on Game Development See other posts from Game Development or by user3251606
Published on 2014-06-11T23:42:16Z Indexed on 2014/06/12 3:53 UTC
Read the original article Hit count: 128

Filed under:
|
|

Ok so i am working on a plugin for my server that will open and inventory and when closed it will pass items to this class... object of this class is to cycle through the inventory and use a cfg file to define items and prices and then grab that info in a for loop and add it all up... heres what i have thus far...

public void sell(Player p, Inventory inv) {

    ListIterator<ItemStack> it = inv.iterator();
    double total = 0;
    for (ItemStack is : inv) {
        is = it.next();
        if (is.getType() != null) {
            String type = is.getType().toString();
            //short dur = is.getDurability();
            String check = ChestSell.plugin.getConfig().getString(type);
            p.sendMessage("Item Type: " + type);
            if (check != null) {

                    int amou = is.getAmount();
                    double value = ChestSell.plugin.getConfig().getDouble(type + ".price");
                    double tv = amou * value;
                    p.sendMessage("Items in chest: Type " + type + " Ammount: " + amou + " Value: $" + tv);
            }

            //TODO Add return Items

        }

    }

    p.sendMessage("You got paid $" + total + " for your items!");
    inv.clear();

}

© Game Development or respective owner

Related posts about java

Related posts about minecraft